package com.rd.sys.common.fileexport.inter.impl;

import java.util.ArrayList;
import java.util.List;

import baseproj.common.exception.BaseServiceException;

import com.rd.sys.common.fileexport.inter.ExportOperator;
import com.rd.sys.dto.analysis.statistic.StatisticExportDto;
import com.rd.sys.dto.client.store.statistic.StatisticFixationData;
import com.rd.sys.dto.commmon.base.BaseDto;
import com.rd.sys.service.analysis.statistic.StatisticService;

public class StatisticPipilDataExport extends ExportOperator {

    @Override
    public List<String> operation(BaseDto dto, String splitSign) throws BaseServiceException, Exception {
        StatisticService statisticService = (StatisticService) getService("statisticServiceImpl");

        StatisticExportDto exportDto = (StatisticExportDto) dto;

        List<StatisticFixationData> statDataList = statisticService.queryFixationDataList(exportDto.getUserCode(),
                exportDto.getProjectCode(), exportDto.getSchemeCode(), exportDto.getResultCode(),
                exportDto.getMaterialCode(), exportDto.getPage());

        List<String> contentList = new ArrayList<String>();

        StringBuilder content = new StringBuilder();
        for (StatisticFixationData fixationData : statDataList) {
            content.append(fixationData.getResultName()).append(splitSign);
            content.append(fixationData.getMaterialName()).append(splitSign);
            content.append(fixationData.getFixationStart()).append(splitSign);
            content.append(fixationData.getFixationDuration()).append(splitSign);
            content.append(fixationData.getFixationEnd()).append(splitSign);
            content.append(fixationData.getLeftPupilSize()).append(splitSign);
            content.append(fixationData.getLeftMaxPupilSize()).append(splitSign);
            content.append(fixationData.getRightPupilSize()).append(splitSign);
            content.append(fixationData.getRightMaxPupilSize()).append(splitSign);

            contentList.add(content.toString());
            content.delete(0, content.length());
        }
        return contentList;
    }
}
